---
title: 'Replication Archive for "Rebels, Revenue, and Redistribution: The Political
  Geography of Post-Conflict Power-Sharing in Africa"'
author: "Felix Haass, Martin Ottmann"
date: ""
output: 
  html_document:
    theme: cosmo
    highlight: tango
    toc: true
    toc_float:
      collapsed: false
      smooth_scroll: false

---


<style type="text/css">
pre code, pre, code {
  white-space: pre !important;
  overflow-x: scroll !important;
  word-break: keep-all !important;
  word-wrap: initial !important;
} 

.table {

    width: 100%;

}

</style>


# Overview

This folder contains code and data files necessary to replicate the analysis of the paper "Rebels, Revenue, and Redistribution: The Political Geography of Post-Conflict Power-Sharing in Africa" by Felix Haass and Martin Ottmann. 

All analyses were conducted in `r R.Version()$version.string`. See below for the package versions with which the results were obtained.

# Folder Structure

The replication archive contains the following folders:

- `./code/`: Contains all the scripts necessary to replicate figures and tables in the paper and appendix. It also contains auxiliary functions loaded by the replication scripts. 

- `./data/`: Contains all the data files necessary for the scripts in `./code/` to run. 

- `./plots/`: All the plots produced by the scripts in `./code/` will be saved here. 

- `./tables/`: All the tables produced by the scripts in `./code/` will be saved here. 

In addition, the archive folder contains the following files:

- `README.rmd` & `README.html`: This file and the markdown script to generate this file.

- `replication_archive.rproj`: The R project file to run the scripts. 

# Replication Instructions

## Necessary packages

Before running the replication file, you need to install the following packages (if you haven't already) for the replication code to run properly. You can copy & paste & run the code below to install the packages and all necessary dependencies. 

For installation of some of these packages you might need to start a fresh R session.

```{r, eval=FALSE}

install.packages("lfe")
install.packages("sf")
install.packages("tidyverse")
install.packages("broom")
install.packages("stargazer")
install.packages("countrycode")
install.packages("haven")
install.packages("caret")
install.packages("doParallel")
install.packages("geosphere")
install.packages("Rcpp")
install.packages("RcppArmadillo")
install.packages("cshapes")

```

## Run the Replication

To run the replication, execute the following steps. 

1. Open `replication_archive.rproj` in RStudio. 
2. Open `README.rmd`. 
3. Remove the commented lines in the R code chunk directly below this list.
4. Press Ctrl+Shift+K or press the `Knit` button in RStudio. 

```{r, warning=FALSE, message=FALSE, error=FALSE, results='hide'}
 
# source("./code/RRR_tables_plots_paper.R")
 
# source("./code/RRR_tables_plots_appendix.R")


```

You should find all plots and tables in the respective `./plots/` and `./tables/` folders.

File paths in all scripts are relative to the root folder of the R project file `replication_archive.rproj` and should work independently of your setup. 

Alternatively, you can run the replication files manually: 

1. Open `replication_archive.rproj` in RStudio. 
2. Open `./code/RRR_tables_plots_paper.R` or `./code/RRR_tables_plots_appendix.R`. 
3. Run the script by pressing Ctrl+Shift+S in RStudio. 

# Codebook

## Data files

The replication archive contains the following data files in the `./data/` subfolder:


**Grid cell data sets**


*Main data*

- `rrr_data`: This file contains the main data set used for analysis in the paper. 


*Data sets/subsamples for robustness checks* 

- `pa_only_sample`: This file contains a dataset of only countries with a peace agreement, but without executive power-sharing. The data set is used for the placebo test in the appendix.
- `rrr_data_full`: This data set contains both the original data set and the peace agreement sample. It is essentialy a combination of both `rrr_data` and `pa_only_sample`. 
- `rrr_data_post`: While the original data set contains only three years before/after the implementation of the power-sharing arrangement, this data set extends this period by up to six years after the implementation of the PS government. This data set is used for a robustness check in the appendix. 
- `geomatched_gid`: This data set contains a list of contiguous grid cells inside and outside ethnic groups' settlement areas. This data set is used for the geomatching robustness check in the appendix. 

**Alternative Units of Observation**

- `rrr_adm2`: In this data set we aggregate the link between power-sharing and ethnic groups to the ADM2 region. 
- `rrr_epr_growup`: In this data set we aggregate the link between power-sharing and ethnic groups the ethnic group's settlement area. 


** Other data files **

- `./data/map_files`: This folder contains additional data files for generating some of the maps in the paper. 
- `psed_month.rda`: This file is an aggregated version of the [PSED data set](https://journals.sagepub.com/doi/abs/10.1177/0738894214542753) and is used to generate figure 1.

## Variables

### Grid cell data sets

The basis for the grid cell analysis data sets is the [PRIO GRID](http://grid.prio.org/) data set which also provides much of the [detailed documentation](http://grid.prio.org/#/codebook) for many of the variables used in our analysis. 

| variable name | description | Source / Notes |
| ---           | ---         | ---   | 
| `gid`; `gid_fct` | Grid cell ID | PRIO GRID | |
| `year`; `year_fct` | Year | PRIO GRID|
| `country` | Country name | PRIO GRID |
| `country_year`| Country-year fixed effects string | Author | 
| `gwno` | Gleditsch & Ward country identifier | PRIO GRID |
| `time_since_ps` | Time in years since first year of power-sharing | | 
| `cabinetINC` | Dummy variable indicating that an ethnic group in the grid cell is represented through a rebel group in the power-sharing government | Combination of PSED and EPR data sets; see manuscript for description | 
| `cabinetINC_leader` | Same as `cabinetINC` but only for ethnic groups of the rebel group leader | See `cabinetINC` |
| `seniorINC` | Same as `cabinetINC` but only for ethnic groups that occupy senior government positions | See manuscript for senior/nonsenior classification | 
| `econcabINC` | Same as `cabinetINC` but only for ethnic groups that occupy an ministry with economic portfolio | See manuscript for classification | 
| `xcoord`, `ycoord` | Coordinates of grid cell centroid | PRIO GRID  | 
| `number_of_groups_na_rm` | Number of ethnic groups in grid cell  | PRIO GRID; EPR | 
| `gdp_cf` | Gross-cell product, carry forwarded | See PRIO GRID for full source |
| `pop_ip` | Population in cell, missing values interpolated | See PRIO GRID for full source | 
| `brd_rollsum` | Rolling sum of battle deaths in cell for a 3 year window | UCDP GED | 
| `nonstate_rollsum` | Rolling sum of nonstate deaths in cell for a 3 year window | UCDP GED | 
| `eprINC` | At least one ethnic group in grid cell in power according to EPR data | EPR | 
| `nlights_calib_mean`| Night lights in grid cell, calibrated to acocunt for satellite sensitivity changes. All lags/leads of the night light variable are based on this variable. | NOAA; PRIO GRID |
| `nlights_1-5years` | Night lights in grid cell at t+1-5 years | NOAA; PRIO GRID |
| `urban_cf` | Urbanisation degree in grid cell | See PRIO GRID for full source | 
| `agri_gc`| Share of grid cell's land use for agricultural purposes  | See PRIO GRID for full source |
| `capdist` | Distance of grid cell centroid to capital | PRIO GRID |
| `petroleum_dummy_cf` | Dummy indicating presence of petroleum in grid cell | PRIO GRID | 
| `pa_inc` | Dummy variable indicating that an ethnic group in a grid cell is represented by a rebel group that is part of a peace deal, but not in a power-sharing government | Combination of PSED and EPR data sets; see appendix for description | 

### ADM2 Data Set

The source data set for the ADM2 analysis is the ["Global Nighttime Lights at ADM2-Level 1992-2013"](https://datainspace.org/index.php/global-nighttime-lights-at-adm2-level-1992-2013/) data set (GNLADM2) by Paul Raschky.

| variable name | description | Source / Notes |
| --- | --- | ---  |
| `countryname` | Country name | GNLADM2 |
| `countrycode` | Gleditsch & Ward country code | GNLADM2 | 
| `ADM2ID` | ADM2 Numeric ID | GNLADM2 |
| `year` | Year | GNLADM2  |
| `country_year` | Country-year string | Authors | 
| `cabinetINC` | See grid cell level variable, aggregated on ADM2 level instead of grid cell | Authors based on link between PSED + EPR | 
| `seniorINC`, `econcabINC`, `cabinetINC_leader` | See grid cell level variable | Authors | 
| `sum_light` | sum of night lights in ADM2 in year | GNLADM2 |
| `nlights_plus1-3` | lead of `sum_light` for years t + 1-3 | GNLADM2 | 


### EPR Settlement Area Data Set

We use the [GROWup](https://growup.ethz.ch) tool to extract the source file for the EPR group settlement area data set. 

| variable name | description | Source / Notes |
| --- | --- | ---  |
| `gwgroupid` | GW group id from EPR | EPR | 
| `countries_gwid` | Gleditsch & Ward Country ID |  EPR | 
| `year` | Group-Year | EPR | 
| `groupname` | Character string of group name | EPR |
| `countryname`| Character string of country name | EPR |
| `country_year_fct` | character string of country-year fixed effect | Authors | 
| `cabinetINC` | Dummy indicating an ethnic group's representation in the power-sharing government | Authors based on PSED + EPR | 
| `seniorINC`, `econcabINC`, `cabinetINC_leader` | See grid cell level variable | Authors | 
| `nightlight_corr_zero` | night lights in settlement area | NOAA, aggregated by EPR | 
| `nlight_plus1-3` | Leads of `nightlight_corr_zero` for 1-3 years | NOAA, aggregated by EPR|

# Package Versions

```{r}

sessionInfo()

```



  
